#!/usr/bin/ruby
# -*- ruby -*-

require 'optparse'

debug = false

OptionParser.new do |o|
    o.on("--debug") { debug = true }
end.parse!

line_no = 0

ARGF.readlines.each do |line|
    puts "[debug] " + line.inspect + " " + line.size.to_s if debug

    bytes = line.bytes.to_a

    while (s = bytes.shift(18))
        puts sprintf("%08x", line_no).tr('a-z', 'A-Z') + " " + s.map { |b| sprintf("%02x", b).tr('a-z', 'A-Z') }.join(" ")

        line_no += 1

        break if s.size < 18
    end
end
